def f(n):
    for i in range(2, int(n**0.5)+1):
        if n%i == 0:
            return False
    return True
n = int(input())
arr = [0]
for i in range(4):
    chislo = n[i]
    if f(int(chislo()):
         arr.append(int(chislo))
    for i in range(i+i,4):
        chislo += n[j]
        if f(int(chislo()):
         arr.append(int(chislo))
print(max(arr))
